using System;
using System.Collections.Generic;
using System.Text;

using Essentials.Persistence;
using Essentials.Environment;

namespace Essentials.BusinessLogic
{
    public abstract class AbstractHandler
    {
        public static void Persist(AbstractView view)
        {
            view.SynchronizeCollections();

            view.MapToBaseEntity().Persist();
        }


        public static void Persist(AbstractView view, TransactionHandler aTransaction)
        {
            view.SynchronizeCollections();

            view.MapToBaseEntity().Persist(aTransaction);
        }


        public static void Delete(AbstractView view, TransactionHandler aTransaction)
        {
            view.MapToBaseEntity().Delete(aTransaction);
        }


        public static void Delete(AbstractView view)
        {
            view.MapToBaseEntity().Delete();
        }


        public static void Delete(AbstractView view, bool cascade)
        {
            view.MapToBaseEntity().Delete(cascade);
        }


        public static void Delete(AbstractView view, bool cascade, TransactionHandler aTransaction)
        {
            view.MapToBaseEntity().Delete(cascade, aTransaction);
        }


        public static bool HasNewKey(AbstractView view)
        {
            return view.MapToBaseEntity().HasNewKey();
        }

    }
}
